{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "http://cover.read.duokan.com/mfsv2/download/fdsc3/p01uLYQyGhZd/OLrfdXxWbnfb2m.jpg!l\n[<div class=\"btn j-buyarea f-cb\">\n\n<a class=\"u-btn j-buy\" hidefocus=\"hidefocus\" href=\"javascript:void(0);\">立即领取</a>\n\n</div>]\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "from bs4 import BeautifulSoup\n",
    "url = r'http://www.duokan.com/book/173282'\n",
    "cover = requests.get(url)\n",
    "cover.encoding = 'utf-8'\n",
    "soup = BeautifulSoup(cover.text, 'html5lib')\n",
    "#print(cover.text)\n",
    "#print(soup.select('.book-wrap')[0])\n",
    "print(soup.select('.book-wrap')[0].select('img')[0]['src'])\n",
    "print(soup.select('.btn'))\n",
    "#if len(soup.select('.u-btn2')) > 0 :\n",
    "#    print(soup.select('.btn'))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
